<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>菜鸟教程(jeeok.com)</title>
<script>
   const handleWindonOpenDerect = () => {
     window.open('https://www.google.com.hk/search?q=store+enhancer&oq=storeEnh&aqs=chrome.1.69i57j0.23150j0j7&sourceid=chrome&ie=UTF-8');
   }

   const handleWindonOpen = () => {
     const leaderTodo = new Promise((resolve) => {
       console.log('leader begin****');
       const fetchInfo = window.fetch('http://baidu.com', {mode: 'no-cors'});
       // const fetchInfo = window.fetch('http://localhost:4000/api', {mode: 'no-cors'});
       setTimeout(() => {
         resolve(fetchInfo);
         }, 1000);
     });
     leaderTodo.then((data) => {
       console.log('first then success', data);
       href = 'https://www.google.com.hk/search?q=store+enhancer&oq=storeEnh&aqs=chrome.1.69i57j0.23150j0j7&sourceid=chrome&ie=UTF-8';
       window.open(href, 'blank1');
       return 'first then success return';
     }, (reason) => {
       console.log('first then reject', reason);
       return 'first then reject return';
     }).catch((reason) => {
       console.log('catch reason', reason);
     });
   }

</script>
</head>
<body>

<h1>我的第一个 JavaScript 程序</h1>
<p id="demo">这是一个段落</p>

<button type="button" onclick="displayDate()">显示日期</button>
   <button onclick='handleWindonOpen()'>promise 打开window</button>
   <button onclick='handleWindonOpenDerect()'>直接打开window</button>
</body>
</html>
